package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisRegion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * created by wangjunfu on 2018-11-26 15:06:32
 */
public class AnalysisRegionDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisRegionDao.class);

    public AnalysisRegion insert(final AnalysisRegion analysisRegion) {
        insert("AnalysisRegion.insert", analysisRegion);
        return analysisRegion;
    }

    public Boolean updateInfoById(final AnalysisRegion analysisRegion) {
        return update("AnalysisRegion.updateInfoById", analysisRegion) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisRegion.updateInfoByQuery", query) > 0;
    }

    public AnalysisRegion selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("AnalysisRegion.selectById", query);
    }

    public List<AnalysisRegion> selectByQuery(final Query query) {
        return queryForList("AnalysisRegion.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisRegion.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        AnalysisRegion analysisRegion = new AnalysisRegion();
        //analysisRegion.setDeleteFlag(1);
        analysisRegion.setId(id);

        return update("AnalysisRegion.updateInfoById", analysisRegion) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisRegion.deleteById", query) > 0;
    }
}